package site.icesky.springboot.feign;

import com.alibaba.fastjson.JSONObject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@SpringBootApplication
@RestController
//@EnableFeignClients(basePackages = "site.icesky.springboot.feign.config")
public class SpringTestApplication {
    private static final Logger logger = LoggerFactory.getLogger(SpringTestApplication.class);

    public static void main(String[] args) {
        SpringApplication.run(SpringTestApplication.class,
                    "--spring.application.name=SpringLog2",
                "--server.port=9000");
    }

    @RequestMapping("/api")
    @ResponseBody
    public JSONObject printDate(@RequestBody JSONObject req) {

        logger.info("API收到请求: [" + req.toJSONString() + "]");

        JSONObject res = new JSONObject();

        res.put("date", new Date().toString());

        return res;
    }
}
